package org.example.rubbish.mapper;


import org.apache.ibatis.annotations.*;
import org.example.rubbish.entity.PriceConfig;

@Mapper
public interface PriceConfigMapper {
    @Insert("INSERT INTO price_config(weight_to_points, points_to_money, operator) " +
            "VALUES(#{weightToPoints}, #{pointsToMoney}, #{operator})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(PriceConfig config);

    @Update("UPDATE price_config SET weight_to_points=#{weightToPoints}, points_to_money=#{pointsToMoney}, " +
            "operator=#{operator}, update_time=NOW() WHERE id=#{id}")
    void update(PriceConfig config);

    @Select("SELECT * FROM price_config ORDER BY id DESC LIMIT 1")
    PriceConfig selectLatest();
}